<!DOCTYPE html>
<html class="x-admin-sm">
    
    <head>
        <meta charset="UTF-8">
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
        <link rel="stylesheet" href="<?php echo __ACSS__;?>/font.css">
        <link rel="stylesheet" href="<?php echo __ACSS__;?>/xadmin.css">
        <!-- <link rel="stylesheet" href="./css/theme5.css"> -->
        <script src="<?php echo __ALIB__;?>/layui/layui.js" charset="utf-8"></script>
        <script type="text/javascript" src="<?php echo __AJS__;?>/xadmin.js"></script>
        <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
        <!--[if lt IE 9]>
        <script src="<?php echo __AJS__;?>/html5.min.js"></script>
        <script src="<?php echo __AJS__;?>/respond.min.js"></script>
        <![endif]-->
    </head>
    <body>
        <div class="layui-fluid">
            <div class="layui-row">
                <form class="layui-form">
                    <input type="hidden" name="id" value="<?php echo $data['id']; ?>">
                    <div class="layui-form-item">
                        <label for="cat_name" class="layui-form-label">
                            <span class="x-red">*</span>分类名称</label>
                        <div class="layui-input-inline">
                            <input type="text" id="title" name="title" placeholder="<?php echo $data['title']; ?>" autocomplete="off" class="layui-input" style="width:75%;">
                        </div>
                        <div class="layui-form-mid layui-word-aux">
                            <span class="x-red">*</span>请输入分类名称</div></div>
                    <label for="L_repass" class="layui-form-label"></label>
                    <label class="layui-btn" onclick="add()">保存</label>
                </form>
            </div>
            </div>
        <script>layui.use(['form', 'layer','jquery'],
            function() {
                $ = layui.jquery;
                var form = layui.form,
                layer = layui.layer;

//                form.on('switch(is_open)', function(obj){
//                    var status = $("input[name='status']:checked").val();
//                    alert(status);
//                })
            });
        function add() {
            var title = $("#title").val();
            //异步提交
            $.post("/index.php/admin/adminCate/cateEdit",{id:<?php echo $id;?>,title:title}, function (res) {
                res = JSON.parse(res);
                if (res.code==500){
                    layer.alert(res.data, {
                        icon: 5
                    })
                }else{
                    layer.alert(res.data, {
                        icon: 6
                    }, function() {
                        //关闭当前frame
                        xadmin.close();
                        // 可以对父窗口进行刷新
                        xadmin.father_reload();
                    });
                    return false;
                }
            });
//                    $.ajax({
//                        url: "<?php echo ADMIN;?>/catadd.php",
//                        type: "post",
//                        dataType:'JSON',
//                        data:data.field,
//                        success: function (res) {
//                            if (res.code==500){
//                                layer.alert(res.data, {
//                                    icon: 5
//                                })
//                            }else{
//                                layer.alert(res.data, {
//                                    icon: 6
//                                }, function() {
//                                    //关闭当前frame
//                                    xadmin.close();
//                                    // 可以对父窗口进行刷新
//                                    xadmin.father_reload();
//                                });
//                            }
//                        },
//                        error:function (res) {
//                            console.log('false='+res);
//                        }
//                    });
        };
        </script>
    </body>

</html>